package com.yjc.rabbitMQ.eight;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;
import com.yjc.rabbitMQ.utils.RabbitMQUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * @author shkstart
 * @create 2022-08-02 11:55
 */
public class Consumer02 {

    //死信交换机
    private static final String DEAD_EXCHANGE = "dead_exchange";
    //死信队列
    private static final String DEAD_QUEUE = "dead_queue";

    public static void main(String[] args) throws Exception {
        Channel channel = RabbitMQUtils.getChannel();

        //声明死信队列
        channel.queueDeclare(DEAD_QUEUE, false, false, false, null);
        channel.queueBind(DEAD_QUEUE, DEAD_EXCHANGE, "lisi");

        DeliverCallback deliverCallback = (consumerTag, message) -> {
            System.out.println("Consumer02(死信队列)接收消息是：" + new String(message.getBody(), "UTF-8"));
        };

        channel.basicConsume(DEAD_QUEUE, true, deliverCallback, (consumerTag) -> {
        });

    }
}
